﻿using Infrastructure.Pub;
using Infrastructure.Tool;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DormMS.IService;
using DormMS.Model;
using DormMS.Model.ViewModels;

namespace DormMS.Controllers
{
    public class HomeController : BaseController
    {
        protected IOrderService orderservice;
        protected IProductService productservice;
        protected IMemberService memberservice;
        public HomeController(IUserInfoService s, IOrderService _orderservice, IProductService _productservice, IMemberService _memberservice) : base(s) {
            orderservice = _orderservice;
            productservice = _productservice;
            memberservice = _memberservice;
        }

        // GET: Home
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Default()
        {
            return View();
        }

        public ActionResult UpdatePassWord()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Logout()
        {
            var cm = CacheManager<CacheUserInfo>.GetInstance();
            string uid = Generator.GetCookie(PubConst.CookieUserKey);
            Generator.ClearCookie(PubConst.CookieUserKey);
            string uniqueKey = string.Format(PubConst.CacheUserKey, uid);
            cm.Remove(uniqueKey);
            return Json("ok");
        }

        [HttpGet]
        public ActionResult HomePage()
        {
            return View();
        }

        [HttpPost]
        public ActionResult GetSaleMoney()
        {
            var model = orderservice.GetSaleMoney();
            return Json(model);
        }

        [HttpPost]
        public ActionResult GetShipmentPending()
        {
            var model = orderservice.GetShipmentPending();
            return Json(model);
        }
        [HttpPost]
        public ActionResult GetStatisticsLower()
        {
            var model = productservice.GetStatisticsLower();
            return Json(model);
        }

        [HttpPost]
        public ActionResult GetStatisticsUpper()
        {
            var model = productservice.GetStatisticsUpper();
            return Json(model);
        }


        [HttpPost]
        public ActionResult GetAddMember()
        {
            var model = memberservice.GetAddMember();
            return Json(model);
        }


        [HttpPost]
        public ActionResult GetStocNotEnoughk()
        {
            var model = productservice.GetStocNotEnoughk();
            return Json(model);
        }


        public ActionResult GetStockEmpty()
        {
            var model = productservice.GetStockEmpty();
            return Json(model);
        }


        public ActionResult GetReturnGoodsCount()
        {
            var model = orderservice.DaiReturnGoodsCount();
            return Json(model);
        }

        public ActionResult GetReingGoodsCount()
        {
            var model = orderservice.DoingReturnGoodsCount();
            return Json(model);
        }


        public ActionResult Getdaipingjia()
        {
            var model = orderservice.Getdaipingjia();
            return Json(model);
        }

        public ActionResult Getyipingjia()
        {
            var model = orderservice.Getyipingjia();
            return Json(model);
        }
    }
}